class CreateUsers < ActiveRecord::Migration
  def self.up
    create_table :users do |t|
      t.string :login, :null => false
      t.text :email, :null => false
      t.string :crypted_password, :null => false
      t.string :password_salt, :null => false
      t.string :persistence_token, :null => false
      t.string :single_access_token
      t.string :perishable_token
      t.integer :login_count, :null => false, :default => 0
      t.integer :failed_login_count
      t.datetime :last_request_at
      t.datetime :current_login_at
      t.datetime :last_login_at
      t.string :current_login_ip
      t.string :last_login_ip
      t.boolean :enabled, :null => false, :default => true

      t.timestamps
    end

    add_index :users, :login, :unique => true
    add_index :users, :persistence_token, :unique => true
    add_index :users, :last_request_at
  end

  def self.down
    remove_index :users, :column => :login
    remove_index :users, :column => :persistence_token
    remove_index :users, :column => :last_request_at
    drop_table :users
  end
end
